import { getRequest, postRequest, putRequest, deleteRequest } from "../http.js"


// let visitors = (data) => {
// 	return new Promise((reslove,reject) =>{
// 		postRequest('ob/visit/getVisitCount',data).then(res => {
// 			reslove(res)
// 		})
// 	})
// }

//访客页面顶部
let visitors = (type) => {
  return new Promise((reslove, reject) => {
    getRequest(`ob/visit/getVisitCount?type=${type}`).then(res => {
      reslove(res)
    })
  })
}
//访客页面图表
let visitorChart = (type) => {
  return new Promise((reslove, reject) => {
    getRequest(`ob/visit/getRecentVisitor?type=${type}`).then(res => {
      reslove(res)
    })
  })
}

//能源页面顶部
let energyTop = (data) => {
  return new Promise((reslove, reject) => {
    postRequest('/api/iot/getDeviceCount', data).then(res => {
      reslove(res)
    })
  })
}

//能源页面排行榜
let energyList = (data) => {
  return new Promise((reslove, reject) => {
    postRequest('/api/iot/getTop', data).then(res => {
      reslove(res)
    })
  })
}

//能源页面图表（三个月用量）
let energyChart = (data) => {
  return new Promise((reslove, reject) => {
    getRequest('/ob/energy/getThreeMonth?type=' + data).then(res => {
      reslove(res)
    })
  })
}

//车位引导页顶部
let stallTop = (type) => {
  return new Promise((reslove, reject) => {
    getRequest(`ob/parking/selectParkLotCount?type=${type}`).then(res => {
      reslove(res)
    })
  })
}

//车位引导页图表
let stallChart = (type) => {
  return new Promise((reslove, reject) => {
    getRequest(`ob/parking/selectCarFlow?type=${type}`).then(res => {
      reslove(res)
    })
  })
}

//梯控顶部
let elevatorTop = (type) => {
  return new Promise((reslove, reject) => {
    getRequest(`ob/eds/selectElevatorCount?type=${type}`).then(res => {
      reslove(res)
    })
  })
}

//梯控图表
let elevatorChart = (type) => {
  return new Promise((reslove, reject) => {
    getRequest(`/ob/eds/selectElevatorSituation?type=${type}`).then(res => {
      reslove(res)
    })
  })
}

//捡漏排行
let missCheckRanking = (data) => {
  return new Promise((reslove, reject) => {
    getRequest(`/ob/patrol/missCheckRanking?type=${data.type}&start=${data.start}&end=${data.end}`).then(res => {
      reslove(res)
    })
  })
}

//捡漏图标
let selectPatrolCount = (data) => {
  return new Promise((reslove, reject) => {
    getRequest(`/ob/patrol/selectPatrolCount?type=${data.type}&start=${data.start}&end=${data.end}`).then(res => {
      reslove(res)
    })
  })
}

//梯控图表
let patrolChart = (type) => {
  return new Promise((reslove, reject) => {
    getRequest(`ob/patrol/selectPatrolCount?type=${type}`).then(res => {
      reslove(res)
    })
  })
}

//消防页面顶部
let controlTop = () => {
  return new Promise((resolve, reject) => {
    postRequest('/ob/security/getStatusCount').then(res => {
      resolve(res)
    })
  })
}

//消防页面柱状图1
let getDeviceByType = () => {
  return new Promise((resolve, reject) => {
    postRequest('/ob/security/getDeviceByType').then(res => {
      resolve(res)
    })
  })
}

//消防页面报警分类
let getAlarmByType = () => {
  return new Promise((resolve, reject) => {
    postRequest('/ob/security/getAlarmByType').then(res => {
      resolve(res)
    })
  })
}

//消防页面报警分类趋势
let getAlarmTrend = (data) => {
  return new Promise((resolve, reject) => {
    getRequest(`/ob/security/getAlarmTrend?time=${data}`).then(res => {
      resolve(res)
    })
  })
}

//消防页面报警
let getAlarmTopTen = () => {
  return new Promise((resolve, reject) => {
    postRequest('/ob/security/getAlarmTopTen').then(res => {
      resolve(res)
    })
  })
}

//告警区域统计
let getWarnAreaStatistics = () => {
  return new Promise((resolve, reject) => {
    postRequest('/ob/security/warnAreaStatistics').then(res => {
      resolve(res)
    })
  })
}

//门禁top
let queryAccessDevicesCount = (type) => {
  return new Promise((resolve, reject) => {
    getRequest('/ob/access/queryAccessDevicesCount?type=' + type).then(res => {
      resolve(res)
    })
  })
}

//门禁chart
let queryAccessRecordsCount = (type) => {
  return new Promise((resolve, reject) => {
    getRequest('/ob/access/queryAccessRecordsCount?type=' + type).then(res => {
      resolve(res)
    })
  })
}

//能源趋势图
let getEnergytrend = (params) => {
  return new Promise((resolve, reject) => {
    getRequest('ob/energy/getEnergyTrend?datetype=' + params.datetype + '&type=' + params.type).then(res => {
      resolve(res)
    })
  })
}
const countElevatorRunTime = () => {
  return new Promise((resolve, reject) => {
    getRequest('/ob/eds/countElevatorRunTime').then(res => {
      resolve(res)
    })
  })
}

const countElevatorFault = (type) => {
  return new Promise((resolve, reject) => {
    getRequest('/ob/eds/countElevatorFault?type=' + type).then(res => {
      resolve(res)
    })
  })
}

export {
  visitors,
  visitorChart,
  energyTop,
  energyList,
  energyChart,
  stallTop,
  stallChart,
  elevatorTop,
  elevatorChart,
  patrolChart,
  controlTop,
  missCheckRanking,
  selectPatrolCount,
  getDeviceByType,
  getAlarmByType,
  getAlarmTrend,
  getAlarmTopTen,
  queryAccessDevicesCount,
  queryAccessRecordsCount,
  getEnergytrend,
  getWarnAreaStatistics,
  countElevatorRunTime,
  countElevatorFault
}
